import { createRouter, createWebHistory } from "vue-router";

const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login.vue"),
  },
  {
    path: "/home",
    name: "Home",
    component: () => import("@/views/home.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(), //history模式使用HTML5模式
  routes,
});

export function resetRouter() {
  const newRouter = createRouter({
    history: createWebHistory(),
    routes,
  });

  router.matcher = newRouter.matcher; // reset router
}

// router.beforeEach(async(to, from, next) => {

// })

export default router;
